import request from "../utils/request";

/**
 *
 * @param userId 用户id
 * @param userName 用户名
 * @param articleId 文章ID
 * @param resourceType 文章：1  评论：2
 * @param actionType   点赞：1  收藏：2
 * @returns {never}
 */
export function addFavourite(userId,userName,articleId,resourceType,actionType,commentId) {
  return request({
    url:'blog/favourites/',
    method: 'post',
    data:{
      userId:userId,
      userName:userName,
      articleId:articleId,
      resourceType:resourceType,
      actionType:actionType,
      commentId:commentId
    }
  })
}


export function getByArticleIdAndUserId(articleId,userId) {
  return request({
    url:'blog/favourites/',
    method: 'get',
    params:{
      articleId:articleId,
      userId:userId
    }
  })
}

/**
 * 移除文章的点赞、或者收藏
 * @param userName 用户名
 * @param articleId  文章ID
 * @param actionType 1点赞、2收藏
 * @returns {never}
 */
export function removeFavourite(userName,articleId,actionType) {
  return request({
    url:'blog/favourites/',
    method: 'delete',
    params:{
      userName:userName,
      articleId:articleId,
      actionType:actionType
    }
  })
}


export function removeCommentLike(commentId,userName,) {
  return request({
    url:'blog/favourites/',
    method: 'delete',
    params:{
      commentId:commentId,
      userName:userName
    }
  })
}




export function getLikeCount() {
  return request({
    url:'blog/favourites/total/',
    method: 'get'
  })
}




